//
//  MJQuizzesViewModel.m
//  MJ
//
//  Created by lina on 2017/12/11.
//  Copyright © 2017年 lina. All rights reserved.
//
#define API_Problem     MJ_DOMAINURL@"minapp/lovetest/problem.php"
#define API_AddProblem  MJ_DOMAINURL@"minapp/lovetest/addTestLog.php"


#import "MJQuizzesViewModel.h"
#import "MJQuestionsModel.h"

@implementation MJQuizzesViewModel

+(void)requestQuizzesDataWithID:(NSString *)idString Success:(void (^) (MJQuestionsModel *questions))requestSuccess failure:(void(^)(NSError *error))requestFailure netWorkState:(void (^) (BOOL netWorkState))netWorkState{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[NSString stringWithFormat:@"%@",idString] forKey:@"id"];
    [[MJNetWorkTool sharedUtil] requestAFURL:API_Problem httpMethod:1 parameters:dic succeed:^(id dict) {
        
        if ([[dict objectForKey:@"flag"] isEqualToString:@"001"]) {
            MJQuestionsModel *model = [MJQuestionsModel modelWithDictionary:[dict objectForKey:@"content"]];
            requestSuccess(model);
        }
        
    } failure:^(NSError *err) {
        
    }];
}


/** add测试题 */
+(void)requestAddQuizzesDataWithProblemID:(NSString *)idString
                                   Result:(NSString *)result
                                  Success:(void (^) (NSString *message))requestSuccess
                                  failure:(void(^)(NSError *error))requestFailure
                             netWorkState:(void (^) (BOOL netWorkState))netWorkState{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[NSString stringWithFormat:@"%@",idString] forKey:@"problemid"];
    [dic setObject:[NSString stringWithFormat:@"%@",result] forKey:@"result"];

    [[MJNetWorkTool sharedUtil] requestAFURL:API_AddProblem httpMethod:1 parameters:dic succeed:^(id dict) {
        
        if ([[dict objectForKey:@"flag"] isEqualToString:@"001"]) {
            requestSuccess([dict objectForKey:@"content"]);
        }
        
    } failure:^(NSError *err) {
        
    }];
}
@end
